package cn.itcast.source;

import lombok.Data;
import org.apache.flink.api.common.RuntimeExecutionMode;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction;

/**
 * @author KTL
 * @version V1.0
 * @Package cn.itcast.source
 * @date 2021/2/23 0023 11:00
 * @Copyright © 2015-04-29  One for each, and two for each
 *  演示：DataStream-Source 自定义数据源-RichParallelSourceFunction
 */
public class SourceDemo04_Customer {
    public static void main(String[] args) throws Exception {
        //TODO 1、source
         StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
         env.setRuntimeMode(RuntimeExecutionMode.AUTOMATIC);
        final DataStreamSource<String> line = env.socketTextStream("node-1", 9999);
        //TODO 2、transformation
        //TODO 3、sink
        line.print();
        //TODO 4、execute
        env.execute();
    }
    @Data
    public static class Order{
        private  String  id;
        private Integer userId;
        private  Integer money;
        private Long createTime;
    }
    public static class MyOrederSurce extends RichParallelSourceFunction<Order>{

        @Override
        public void run(SourceContext<Order> ctx) throws Exception {

        }

        @Override
        public void cancel() {

        }
    }

}


